Attribute VB_Name = "LOCutus"
Option Explicit

Public Sub StartLOCutus()

Dim frm As frmBookSheetSelect
    
    Set frm = New frmBookSheetSelect
    
    With frm
        .ShowSheets = False
        .Show vbModal
        If .BookSelected Then
            ProduceLOCutusReport Workbooks(.SelectedBookName)
        End If
    End With
    
    Unload frm
    Set frm = Nothing

End Sub

Public Sub ProduceLOCutusReport(book As Workbook)

Dim mods As VBModules
Dim reader As IVBModuleReader
Dim newMod As VBModule
Dim comp As VBComponent

    Set mods = New VBModules
    
    For Each comp In book.VBProject.VBComponents
    
        Set newMod = New VBModule
        
        Debug.Print comp.Name & ": " & Format(comp.CodeModule.CountOfLines, "####0") & " lines"
        
        If comp.CodeModule.CountOfLines > 0 Then
        
            Set reader = New VBEModuleReader
            
            reader.ConstructFrom comp.CodeModule
            
            newMod.LoadTextFrom reader
            
            mods.AddModule newMod
            
        End If
    Next
    
Dim reportwriter As ILOCReport

    Set reportwriter = New LOCXLReport
    
    reportwriter.printReport mods, "LOCutus"
    
End Sub

